home *** CD-ROM | disk | FTP | other *** search
-
- ******************************************************************************
- * *
- * HodgePodge: An example Apple IIGS Desktop application *
- * *
- * Written in 65816 Assembler by the Apple IIGS Tools Team *
- * Modified by Ben Koning for "Programmer's Introduction to the Apple IIGS" *
- * *
- * Copyright (c) 1986-87 by Apple Computer, Inc. *
- * *
- * ---------------------------------------------------------------------- *
- * *
- * ASM65816 Code file "DIALOG.ASM" -- Various dialogs taking modal control *
- * *
- ******************************************************************************
-
-
-
- ****************************************************************
- *
- * ManyWindDialog -- Warning that too many windows are open.
- *
- ****************************************************************
-
- ManyWindDialog START
- using GlobalData
-
- pha
- pushlong #OurAlert
- pushlong #$0000
- _CautionAlert
- pla ; get the item hit
- rts
-
- OurAlert dc i'30,120,80,520' ; bounds rect
- dc i'2374' ; id
- dc h'80'
- dc h'80'
- dc h'80'
- dc h'80'
- dc i4'item1'
- dc i4'item2'
- dc i4'0000'
-
- item1 dc i2'1' ; id
- dc i2'25,320,00,00' ; bounds rect for button
- dc i2'ButtonItem' ; type
- dc i4'But1' ; item descreptor
- dc i2'00' ; item value
- dc i2'0' ; item flag
- dc i4'0' ; item color
-
- item2 dc i2'1348' ; id
- dc i2'11,72,200,640' ; bounds rect for message
- dc i2'StatText+$8000' ; type + disabled
- dc i4'Msg' ; item descreptor
- dc i2'00' ; item value
- dc i2'0' ; item flag
- dc i4'0' ; item color
-
- But1 str 'OK'
- Msg str 'No more windows, please.'
-
- end
-
-
-
- ****************************************************************
- *
- * DoAboutItem
- *
- * Brings up about box and waits until button press until
- * it puts it away. Shows how to build a dialog window by hand.
- *
- ****************************************************************
-
- DoAboutItem START
- using globalData
-
- PushLong #0 ; get space for Icon
- PushLong #34*16+8 ; #lines * bytes/line + rect
- PushWord MyId
- PushWord #0 ; don't care where it goes
- PushLong #0
- _NewHandle
- pla
- plx
- bcc ok
- lda #$81 ; out of memory
- ldx #1
- jmp CheckDiskError ; Go and tell user error message,
- ; ; and use its RTS to exit from here.
-
- ok anop
- sta AppleIconH
- stx AppleIconH+2
-
- jsr deref
-
- sta 0
- stx 2
-
- ldy #0 ;move Icon to new space
- Copy640 lda AppleIcon640,y
- sta [0],y
- iny
- iny
- cpy #34*16+8
- bne Copy640
-
- FixDBox ldx #160+10
- lda #640-160-10
-
- JoinRect stx DRect+2
- sta DRect+6
-
- PushLong #0 ; output
- PushLong #DRect
- PushWord #True ; visible
- PushLong #0 ; refcon
- _NewModalDialog
-
- pla
- sta MDialogPtr
- pla
- sta MDialogPtr+2
-
- PushLong MDialogPtr
- PushWord #1
- PushLong #ButtonRect
- PushWord #ButtonItem
- PushLong #ButtonText
- PushWord #0
- PushWord #0
- PushLong #0
- _NewDItem
-
- PushLong MDialogPtr
- PushWord #2
- PushLong #AppleIconRect
- PushWord #IconItem+ItemDisable
- PushLong AppleIconH
- PushWord #0
- PushWord #0
- PushLong #0
- _NewDItem
-
- PushLong MDialogPtr
- PushWord #4
- PushLong #TextRect
- PushWord #LongStatText2+ItemDisable
- PushLong #StartOfText
- PushWord #EndOfText-StartOfText
- PushWord #0
- PushLong #0
- _NewDItem
-
- DoModal PushWord #0 ; result
- PushLong #0 ; no filterproc
- _ModalDialog
- pla ; chuck the item hit
-
- PushLong MDialogPtr
- _CloseDialog
-
- PushLong AppleIconH
- _DisposeHandle
-
- rts
-
- DRect dc i'20,10,192,320-10'
-
- AppleIconH ds 4
- AppleIconRect dc i'135,20,0,0'
-
- AppleIcon640 anop
- dc i'0,0,34,64'
- dc h'00000000000000000000000000000000'
- DC h'0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0'
- DC h'0F0000000000000000000000000000F0'
- DC h'0F0FFFFFFFFFFFFFFFFFFFFFFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFFFFFFF88FFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFFFFF8888FFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFFFF88888FFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFFF88888FFFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFF888888FFFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFF88888FFFFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFF8888FFFFFFFFF0F0'
- DC h'0F0FFFFFF8888FFF88FF8888FFFFF0F0'
- DC h'0F0FFFF88888888FFF88888888FFF0F0'
- DC h'0F0FFF888888888888888888888FF0F0'
- DC h'0F0FFeeeeeeeeeeeeeeeeeeeeFFFF0F0'
- DC h'0F0FFeeeeeeeeeeeeeeeeeeeFFFFF0F0'
- DC h'0F0FFeeeeeeeeeeeeeeeeeeFFFFFF0F0'
- DC h'0F0FF666666666666666666FFFFFF0F0'
- DC h'0F0FF666666666666666666FFFFFF0F0'
- DC h'0F0FF666666666666666666FFFFFF0F0'
- DC h'0F0FF4444444444444444444FFFFF0F0'
- DC h'0F0FF44444444444444444444FFFF0F0'
- DC h'0F0FFF444444444444444444444FF0F0'
- DC h'0F0FFF555555555555555555555FF0F0'
- DC h'0F0FFF555555555555555555555FF0F0'
- DC h'0F0FFFF5555555555555555555FFF0F0'
- DC h'0F0FFFF1111111111111111111FFF0F0'
- DC h'0F0FFFFF11111111111111111FFFF0F0'
- DC h'0F0FFFFFF111111FFF111111FFFFF0F0'
- DC h'0F0FFFFFFF1111FFFFF1111FFFFFF0F0'
- DC h'0F0FFFFFFFFFFFFFFFFFFFFFFFFFF0F0'
- DC h'0F0000000000000000000000000000F0'
- DC h'0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0'
- DC h'00000000000000000000000000000000'
-
- TextRect dc i2'4,10,135,280'
- StartOfText anop
- dc h'01',c'J',i'1' ; center
- dc h'01',c'S',i'$0008' ; Outline
- dc c'HodgePodge',h'0D'
- dc h'01',c'S',i'$0000' ; plain
- dc c'A potpourri of routines that '
- dc c'demonstrate many features of '
- dc c'the Apple IIGS Tools.'
- dc h'0D'
- dc h'0D'
- dc c'By Ben Koning and the Apple IIGS '
- dc c'Tools Group:'
- dc h'0D'
- dc c'Eagle I. Berns, Art Cabral, Cheryl Ewy, '
- dc c'Steven Glass, Suki Lee, '
- dc c'Pete McDonald, Bennet Marks, Dan Oliver, '
- dc c'Dan Hitchens, and Keith Rollin.'
- dc h'0D'
- dc c'Copyright Apple Computer, Inc., '
- dc c'1986-87, All Rights Reserved',h'0D'
- dc c'v1.0 '
- dc c'&SysDate'
- EndOfText anop
-
- ButtonRect dc i'153,205,0,0'
-
- ButtonText str 'OK'
-
- MDialogPtr ds 4
-
- END
-
-
-
- ****************************************************************
- *
- * ShowPleaseWait / HidePleaseWait
- *
- * Brings up a window and immediately puts message in it
- * (without waiting for update event).
- *
- ****************************************************************
-
- ShowPleaseWait START
- using globalData
-
- PushLong #0 ; save the current port
- _GetPort
-
- pla
- sta OrigPort
- pla
- sta OrigPort+2
-
- PushLong #0
- PushLong #DialogTemplate
- _GetNewModalDialog
-
- pla
- sta MsgWinPtr
- pla
- sta MsgWinPtr+2
-
- PushLong MsgWinPtr ; begin the updating process
- _BeginUpdate
-
- PushLong MsgWinPtr
- _DrawDialog
-
- PushLong MsgWinPtr
- _EndUpdate
-
- rts
-
- HidePleaseWait ENTRY
- PushLong MsgWinPtr ; hide the window
- _CloseDialog
-
- PushLong OrigPort ; restore the port
- _SetPort
-
- rts
-
- MsgWinPtr ds 4
-
- DialogTemplate anop
- dc i'30,120,80,520' ; bounding box
- dc i'True' ; visible
- dc i4'0' ; refcon
- dc i4'item1'
- dc i4'0000'
-
- item1 anop
- dc i2'1348' ; id
- dc i2'19,70,200,640' ; bounds rect for text
- dc i2'StatText' ; type
- dc i4'Msg' ; item descreptor
- dc i2'00' ; item value
- dc i2'0' ; item flag
- dc i4'0' ; item color
-
- Msg str 'Please wait while we set things up.'
-
- END
-
-
-
- ****************************************************************
- *
- * MountBootDisk
- *
- * This is a routine that is called whenever the application
- * needs to get something off the boot volume and the
- * boot volume is not on line.
- *
- * This can occur when loading fonts, tools or drivers.
- *
- ****************************************************************
-
- MountBootDisk START
-
- _Set_Prefix SetPrefixParams
- _Get_Prefix GetPrefixParams
-
- PushWord #0 ;Space for result
- PushWord #174 ;x pos
- PushWord #30 ;y pos
- PushLong #PromptStr ;Prompt string
- PushLong #VolStr ;Vol string
- PushLong #OKStr
- PushLong #CancelStr
- _TLMountVolume
-
- pla
-
- rts
-
- PromptStr str 'Please insert the disk'
- OKStr str 'OK'
- CancelStr str 'Shutdown'
-
- GetPrefixParams dc i'7'
- dc i4'VolStr'
-
- SetPrefixParams dc i'7'
- dc i4'BootStr'
-
- VolStr ds 16
-
- BootStr str '*/'
-
- END
-
-
-
- ****************************************************************
- *
- * CheckToolError
- *
- * Cause system death if A register is nonzero and carry set;
- * otherwise, it just returns.
- *
- * Error code to make part of string is in A register.
- * "Where" number to make part of string is in X register.
- *
- ****************************************************************
-
- CheckToolError START
-
- bcs RealDeath ;If a tool error didn't happen
- rts ;then just return
-
- RealDeath pha ;Save error code for now
-
- pea 0 ;Convert the "Where" debug trace
- pea 0 ;number to a four-digit ASCII hex
- phx ;string.
- _Hexit
- pla
- sta codes
- pla
- sta codes+2
-
- pla ;Restore error code
-
- pha ;Exit to system failure handler
- PushLong #DeathMsg ;(bouncing apple)
- _SysFailMgr
-
- DeathMsg anop
- dc i1'EndMsg-StartMsg'
- StartMsg dc c' At $'
- Codes ds 4
- dc c'; Could not handle error $'
- EndMsg anop
-
- END
-
-
-
- ****************************************************************
- *
- * CheckDiskError -- Display stop alert dialog if ProDOS error happened.
- * We sniff the A register to see if an error occurred,
- * and assume the X register to be loaded with a
- * "where" value, used to locate bugs.
- *
- ****************************************************************
-
- CheckDiskError START
- using GlobalData
-
- phx ; Save the Where value
- pha ; Save the error number
-
- _InitCursor ; Set pointer--looks better than watch
-
- pla ; Restore the error number
- pha ; Convert the error message
- PushLong #OurErrStr ; to an ASCII string 4 chars long
- PushWord #4
- _Int2Hex
-
- pla ; Do this just for clarity (note that
- pha ; Where value is already on stack!)
- PushLong #OurWhereStr ; Convert the Where value
- PushWord #2 ; to an ASCII string 2 chars long
- _Int2Hex
-
- pha ; Space for result
- pushlong #OurAlert ; Pointer to template
- pushlong #$0000 ; Standard Filter procedure
- _StopAlert ; Draw box and wait for mouse OK press
- pla ; Get the item hit (the OK button)
-
- sec ; Set the error flag
- rts ; Return to caller
-
- OurAlert dc i'30,120,80,520' ; bounds rect
- dc i'6666' ; id
- dc h'80'
- dc h'80'
- dc h'80'
- dc h'80'
- dc i4'OKButton'
- dc i4'Message'
- dc i4'0000'
-
- OKButton dc i2'1' ; id
- dc i2'25,320,00,00' ; bounds rect for button
- dc i2'ButtonItem' ; type
- dc i4'OKName' ; item descreptor
- dc i2'00' ; item value
- dc i2'0' ; item flag
- dc i4'0' ; item color
-
- Message dc i2'1348' ; id
- dc i2'11,72,200,640' ; bounds rect for static text
- dc i2'StatText+$8000' ; type + disable flag
- ErrMsgPtr dc i4'Msg' ; item descreptor
- dc i2'00' ; item value
- dc i2'0' ; item flag
- dc i4'0' ; item color
-
- OKName str 'OK'
-
- Msg dc i1'EndMsg-StartMsg'
- StartMsg dc c'Disk error $'
- OurErrStr ds 4
- dc c' occurred at $'
- OurWhereStr ds 2
- dc c'.'
- dc h'0D'
- EndMsg anop
-
- END
-